package com.example.business.demo.enums;

import lombok.Getter;

/**
 * Demo状态枚举
 * 用于定义Demo实体的各种状态
 */
@Getter
public enum DemoStatusEnum {
    
    INVALID(0, "无效"),
    VALID(1, "有效"),
    PENDING(2, "待处理"),
    PROCESSING(3, "处理中"),
    COMPLETED(4, "已完成");

    private final Integer code;
    private final String description;

    DemoStatusEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据状态码获取枚举值
     * @param code 状态码
     * @return 对应的枚举值，如果没找到返回null
     */
    public static DemoStatusEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (DemoStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
} 